package Tree._116_PopulatingNextRightPointersinEachNode;

public class _116_PopulatingNextRightPointersinEachNode {
    public void connect(TreeLinkNode root) {
        if( root==null || root.left==null ) return;
        TreeLinkNode nxnode = root.next;
        root.left.next = root.right;
        if (nxnode != null) {
            root.right.next = nxnode.left;
        }
        connect(root.left);
        connect(root.right);
    }
}
